<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>意达设计</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../css/dealer.css"/>

</head>
<body class="body">

<!-- header -->
<div class="pageheader">
	<a href="javascript:void(0);" onclick="api.closeWin();" class="return"></a>
	<span>我的经销商</span>
	<a href="javascript:void(0)" class="fotadh" style="display: none"></a>
</div>
<div class="pad">
	<div class="tabshy">
		<table id='con'>
			<tr>
				<td>序号</td>
				<td>经销商名称</td>
				<td>联系人</td>
				<td>联系电话</td>
				<td>操作</td>
			</tr>
			<tr>
				<td>1</td>
				<td>南岸经销商</td>
				<td>张三</td>
				<td>13726571688</td>
				<td><a href="#">编辑</a></td>
			</tr>
			
		</table>
	</div>
	<div class="selelnk" style="display: none;">
		<label>全选<input type="checkbox" class="cheboxs" name=""></label>
		<a href="javascript:void(0)">删除</a>
	</div>
</div>





</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../script/adaptive.js"></script>
<script type="text/javascript" src="../script/swiper.min.js"></script>
<script type="text/javascript" src="../script/tabs.js"></script>
<script type="text/javascript">
    window['adaptive'].desinWidth = 750;
    window['adaptive'].baseFont = 28;
    window['adaptive'].maxWidth = 750;
    window['adaptive'].init();

  var page=1;
    apiready = function () {
        $api.fixStatusBar($api.dom('.header'));
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err){
            api.closeWidget();
        });
        api.showProgress();

        var para=api.pageParam;
      

    	var  p={token:token,page:page};

        toDoRequest();

      /*  api. addEventListener({name:'scrolltobottom'}, function(ret, err){
            
            toDoRequest();

        });*/
        
        

    

  };
  function toDoRequest(){

        	p={token:token};

            api.ajax({
                url: webSiteUrl+'/app/user/myuser',
                method: 'post',
                data: {
                    values:p,
                }
            }, function(ret, err) {
                api.hideProgress();
                
                if(ret.code==200){
                    
                    
                    $('#total').html(ret.data.total);
                    $('#month').html(ret.data.month);

              
                    html = "<tr><td>序号</td><td>经销商名称</td><td>联系人</td><td>联系电话</td><td>操作</td></tr>";
                    var tj=ret.data;
                    if(tj==null){
                        return;
                    }
                    for(var i=0;i<tj.length;i++){


html+='<tr><td>'+parseInt(i+1)+'</td><td onclick="choosejxs('+tj[i].id+')" id="j_'+tj[i].id+'">'+tj[i].addrname+'</td><td>'+tj[i].name+'</td><td>'+tj[i].phone+'</td><td><a href="javascript:void(0)" onclick="edituser('+tj[i].id+')">编辑</a></td></tr>'

                    }
					$('#con').html(html);
            		/*if(page==1){
                        $('#con').html(html);
                    }else{
                        $('#con').append(html);
                    }
                    page++;*/
                }else{
                	
                    $('#con').html('<p style="text-align:center">暂无数据</p>');
                }

		    });
        }

    function choosejxs(dd){
        var para=api.pageParam

        if(para.gid>0 || para.type=='cartuser'){

            var txt=$('#j_'+dd).html();
            $api.setStorage('jxsid',dd);
            $api.setStorage('jxstxt',txt);
            //addrid=id;
            
            if(para.gid>0){

                api.openWin({
                    name: 'loginName',
                    url: './goodsdetail.html',
                    reload:true,
                    pageParam: {
                        id:para.gid,
                        jid:dd,
                    }
                });
            }else if(para.type=='cartuser'){
                api.openWin({
                    name: 'loginName',
                    url: './cart.html',
                    reload:true,
                    pageParam: {
                        jid:dd,
                        
                    }
                });
            }
        }
        
        
    }
    function edituser(id){
        api.openWin({
            name: 'shopName',
            url: './edituser.html',
            pageParam: {
                id: id
            }
        });
    }       

</script>

</html>
